/**
 * 所有生成器的父类，构造方法中实现了读取property文件和导入java 模版的功能
 * @author dengzongrong
 * @version 1.1
 * @date 2011-10-09
 */
package com.lemon.ai.socket.packets.spiritgame.model.generator;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public abstract class AbstractGenerator {

	protected Properties prop = new Properties();
	protected String temp = new String();
	private BufferedReader in;

	/**
	 * 构造方法，读取property文件和导入java模版
	 * @param temp
	 */
	public AbstractGenerator(String temp) {
		String b = null;
		try {
//			System.out.println(System.getProperty("user.dir") + "\\" + temp);
			in = new BufferedReader(new FileReader(new File(
					System.getProperty("user.dir") + "\\temp\\" + temp)));
			while((b = in.readLine()) != null)
				this.temp += b + "\r";
//			System.out.println(this.temp);
			this.prop.load(new FileInputStream(new File(System
					.getProperty("user.dir")
					+ "\\mysql.properties")));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) {
//		AbstractGenerator g = new AbstractGenerator("DaoIfcTemp.txt");
//		System.out.println();
	}

}
